<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>风雪之隅</title>
    <meta name="description" content="asdgasdgasdgasdgasdgasdgasdgdsg" />
    <meta name="keywords" content="dsagt,dsgdsg,sdagadsg" />
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./Tpl/layui/css/layui.css">
    <link rel="stylesheet" href="./Tpl/cms/blog/style.css">

</head>

<body>
    <div class="header">
        <div class="layui-container">
            <div class="biaoti">
                风雪之隅

                <p>左手代码右手诗</p>
            </div>
            <div class="layui-icon layui-icon-menu-fill gengduocd layui-hide-md  layui-hide-lg"></div>
            <ul class=" layui-hide-xs">
                <li><a href="index.html">首页</a></li>
                <li><a href="index.html">源码中心</a></li>
                <li><a href="index.html#http://test.elikeji.com/index.php?list3.html">美术资源</a></li>
                <li><a href="index.html#http://test.elikeji.com/index.php?list4.html">新闻咨询</a> </li>
                <li><a class="layui-this" href="index.html#http://test.elikeji.com/index.php?list5.html">关于我们</a></li>
                <li><a href="index.html#http://test.elikeji.com/index.php?user.html">会员中心</a></li>
                <div style="clear:both;height:1rem;"></div>
            </ul>
            <div id="zuozhede"></div>

        </div>

    </div>
    <div class="neirong">
        <div class="layui-container">
            <div class="layui-row">
                <div class="layui-col-md8 layui-col-xs12">
                    <div class="center ">
                        <h1>
                            PHP8新特性之match表达式
                        </h1>
                        <div class="post-byline">Published on <a class="date" href="https://www.laruence.com/2020/07">13
                                July 2020</a> by <a class="author"
                                href="https://www.laruence.com/author/laruence">laruence</a></div>

                        <!-- 购买列表 -->
                        <div class="post-gouwuche">
                            <div class="layui-row">
                                <div class="layui-col-md5 suoluetu">
                                    <img class="pic" src="https://image.9game.cn/s/9game/g/2018/5/30/20492746.png" alt="六界仙尊">
                                </div>
                                <div class="layui-col-md7 bianxian">
                                    <ul>
                                        <li class="cs"><span>分类:</span><a href="#">网络游戏</a></li>
                                        <li class="cs"><span>时间:</span>2000-1-1</li>
                                        <li class="cs"><span>描述:</span>以前我们可能会经常使用switch做值转换类的工作，类似:以前我们可能会经常使用switch做值转换类的工作，类似:</li>
                                        <li class="cs"> <span>版本:</span>2.0 </li>
                                        <li class="cs"> <span>大小:</span>7.9M </li>
                                        
                                        <li class="cs"><span>推荐:</span><div class="layui-rate-node"></div></li>
                                        <li class="cs"><span>价格:</span><b>$118.00</b> <s>$118.00</s></li>
                                    </ul>
                                    <div class="gogoumai">
                                        <a href="http://www.layui.com" class="layui-btn layui-btn-normal">立即购买</a>
                                        <a href="http://www.layui.com" class="layui-btn ">立即购买</a>
                                    </div>
                                </div>

                            </div> 
                        </div>
                        <div style="clear:both;"></div>

                        <!-- 带图片预览-->
                        <div class="post-tuji layui-carousel" id="test1">
                            <ul carousel-item>
                                <li><img src="https://image.9game.cn/s/9game/g/2018/5/14/20293679.jpg" alt="碰碰糖果"></li>
                                <li> <img src="https://image.9game.cn/s/9game/g/2018/5/14/20293677.jpg" alt="碰碰糖果"></li>
                                <li> <img src="https://image.9game.cn/s/9game/g/2018/5/14/20293672.jpg" alt="碰碰糖果"></li>
                                <li> <img src="https://image.9game.cn/s/9game/g/2018/5/14/20293675.jpg" alt="碰碰糖果"></li>
                                <li><img src="https://image.9game.cn/s/9game/g/2018/5/14/20293671.jpg" alt="碰碰糖果"></li>
                            </ul>

                        </div> 


                        <div class="post-content">

                           
                            <p>PHP8 alpha2发布了，最近引入了一个新的关键字：match, 这个关键字的作用跟switch有点类似。</p>
                            <p>虽然我一般对语法糖无感，但这个我觉得还是有点意思，match这个词也挺好看，那么它是干啥的呢？</p>
                            <p>在以前我们可能会经常使用switch做值转换类的工作，类似:</p>
                            <pre name="code" class="sh_php sh_sourceCode"
                                linenum="off"><ol><li><span class="sh_keyword">switch</span> <span class="sh_symbol">(</span><span class="sh_variable">$input</span><span class="sh_symbol">)</span> <span class="sh_symbol">{</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span class="sh_statement">case</span> <span class="sh_string">"true"</span><span class="sh_symbol">:</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="sh_variable">$result</span> <span class="sh_symbol">=</span> <span class="sh_number">1</span>;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span class="sh_statement">break</span>;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span class="sh_statement">case</span> <span class="sh_string">"false"</span><span class="sh_symbol">:</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="sh_variable">$result</span> <span class="sh_symbol">=</span> <span class="sh_number">0</span>;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span class="sh_statement">break</span>;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span class="sh_statement">case</span> <span class="sh_string">"null"</span><span class="sh_symbol">:</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="sh_variable">$result</span> <span class="sh_symbol">=</span> NULL;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span class="sh_statement">break</span>;</li><li><span class="sh_symbol">}</span></li></ol></pre>
                            <p>(当然，有的同学会说，谁会这么写，用个数组转换不行么？ 拜托，这是举例啊，数组也只能数字键和整数啊，万一key是需要其他表达式呢，万一你要多个key对应一个值呢，对吧？)</p>
                            <p>那么如果使用match关键字呢，可以变成类似:</p>
                            <pre name="code" class="sh_php sh_sourceCode"
                                linenum="off"><ol><li><span class="sh_variable">$result</span> <span class="sh_symbol">=</span> <span class="sh_function">match</span><span class="sh_symbol">(</span><span class="sh_variable">$input</span><span class="sh_symbol">)</span> <span class="sh_symbol">{</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="sh_string">"true"</span> <span class="sh_symbol">=&gt;</span> <span class="sh_number">1</span>,</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="sh_string">"false"</span> <span class="sh_symbol">=&gt;</span> <span class="sh_number">0</span>,</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="sh_string">"null"</span> <span class="sh_symbol">=&gt;</span> NULL,</li><li><span class="sh_symbol">}</span>;</li></ol></pre>
                            <p>相比switch， match会直接返回值，可以直接赋值给$result了。</p>
                            <p>并且，类似switch的多个case一个block一样，match的多个条件也可以写在一起，比如:</p>
                            <pre name="code" class="sh_php sh_sourceCode"
                                linenum="off"><ol><li><span class="sh_variable">$result</span> <span class="sh_symbol">=</span> <span class="sh_function">match</span><span class="sh_symbol">(</span><span class="sh_variable">$input</span><span class="sh_symbol">)</span> <span class="sh_symbol">{</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span class="sh_string">"true"</span>, <span class="sh_string">"on"</span> <span class="sh_symbol">=&gt;</span> <span class="sh_number">1</span>,</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span class="sh_string">"false"</span>, <span class="sh_string">"off"</span> <span class="sh_symbol">=&gt;</span> <span class="sh_number">0</span>,</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span class="sh_string">"null"</span>, <span class="sh_string">"empty"</span>, <span class="sh_string">"NaN"</span> <span class="sh_symbol">=&gt;</span> NULL,</li><li><span class="sh_symbol">}</span>;</li></ol></pre>
                            <p>需要注意的和switch不太一样的是，以前我们用switch可能会经常遇到这种诡异的问题:</p>
                            <pre name="code" class="sh_php sh_sourceCode"
                                linenum="off"><ol><li><span class="sh_variable">$input</span> <span class="sh_symbol">=</span> <span class="sh_string">"2 person"</span>;</li><li><span class="sh_keyword">switch</span> <span class="sh_symbol">(</span><span class="sh_variable">$input</span><span class="sh_symbol">)</span> <span class="sh_symbol">{</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span class="sh_statement">case</span> <span class="sh_number">2</span><span class="sh_symbol">:</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="sh_keyword">echo</span> <span class="sh_string">"bad"</span>;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span class="sh_statement">break</span>;</li><li><span class="sh_symbol">}</span></li></ol></pre>
                            <p>你会发现，bad竟然被输出了，这是因为switch使用了宽松比较(==)。match就不会有这个问题了, 它使用的是严格比较(===)，就是值和类型都要完全相等。</p>
                            <p>还有就是，当input并不能被match中的所有条件满足的时候，match会抛出一个UnhandledMatchError exception:</p>
                            <pre name="code" class="sh_php sh_sourceCode"
                                linenum="off"><ol><li><span class="sh_variable">$input</span> <span class="sh_symbol">=</span> <span class="sh_string">"false"</span>;</li><li><span class="sh_variable">$result</span> <span class="sh_symbol">=</span> <span class="sh_function">match</span><span class="sh_symbol">(</span><span class="sh_variable">$input</span><span class="sh_symbol">)</span> <span class="sh_symbol">{</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="sh_string">"true"</span> <span class="sh_symbol">=&gt;</span> <span class="sh_number">1</span>,</li><li><span class="sh_symbol">}</span>;</li></ol></pre>
                            <p>会得到:</p>
                            <pre name="code" class="sh_bash"
                                linenum="off"><ol><li>Fatal error: Uncaught UnhandledMatchError: Unhandled match value of type string</li></ol></pre>
                            <p>这样就不用担心万一match条件没写全导致了不可预知的错误。</p>
                            <p>另外还是要说明，match是关键字，也就是从PHP8开始它不能出现在namespace或者类名中，如果你的项目中有用match作为类名的:</p>
                            <pre name="code" class="sh_php sh_sourceCode"
                                linenum="off"><ol><li><span class="sh_builtin_types">class</span> Match <span class="sh_symbol">{}</span></li></ol></pre>
                            <p>在PHP8开始将会得到语法错误了, 当然，方法名中还是可以用的。</p>
                            <p>详细的，可以参考RFC：<a href="https://wiki.php.net/rfc/match_expression_v2" target="_blank"
                                    rel="noopener noreferrer">Match Expression</a></p>
                            <p>以上，没了。</p>
                            <p>
                                <script type="text/javascript"
                                    src="https://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js">
                                </script>
                                <script type="text/javascript"
                                    src="https://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_bash.js">
                                </script>
                            </p>
                            <div class="rp4wp-related-posts">
                                <h3>Related Posts</h3>
                                <ul>
                                    <li>
                                        <div class="rp4wp-related-post-content">
                                            <a
                                                href="https://www.laruence.com/2020/06/16/5916.html">使用SSE2指令高效实现strtolower</a>
                                        </div>
                                    </li>
                                    <li>
                                        <div class="rp4wp-related-post-content">
                                            <a href="https://www.laruence.com/2010/07/30/1682.html">注意PHP对字符串的递增运算</a>
                                        </div>
                                    </li>
                                    <li>
                                        <div class="rp4wp-related-post-content">
                                            <a href="https://www.laruence.com/2010/12/17/1833.html">PHP是无辜的</a></div>
                                    </li>
                                    <li>
                                        <div class="rp4wp-related-post-content">
                                            <a href="https://www.laruence.com/2020/06/12/5902.html">PHP
                                                8新特性之Attributes(注解)</a></div>
                                    </li>
                                    <li>
                                        <div class="rp4wp-related-post-content">
                                            <a href="https://www.laruence.com/2011/06/26/2083.html">Yaf已提交到PECL</a>
                                        </div>
                                    </li>
                                </ul>
                            </div>
                        </div>
                        <div class="post-categories">
                            <span>Filed in </span><a href="https://www.laruence.com/category/php8"
                                title="View all posts in PHP8">PHP8</a>, <a
                                href="https://www.laruence.com/category/php-usage"
                                title="View all posts in PHP应用">PHP应用</a>, <a
                                href="https://www.laruence.com/category/notes" title="View all posts in 随笔">随笔</a> <span
                                class="comments-link"> with <a
                                    href="https://www.laruence.com/2020/07/13/6033.html#comments">62 Comments</a></span>
                        </div>
                        <div class="post-tags">
                            <a href="https://www.laruence.com/tag/match" title="View all posts tagged match">match</a>
                            <a href="https://www.laruence.com/tag/match-expression%ef%bc%8cswitch"
                                title="View all posts tagged match expression，switch">match expression，switch</a> <a
                                href="https://www.laruence.com/tag/php-8" title="View all posts tagged PHP 8">PHP 8</a>
                            <a href="https://www.laruence.com/tag/php8" title="View all posts tagged PHP8">PHP8</a>
                            <a href="https://www.laruence.com/tag/match" title="View all posts tagged match">match</a>
                            <a href="https://www.laruence.com/tag/match-expression%ef%bc%8cswitch"
                                title="View all posts tagged match expression，switch">match expression，switch</a> <a
                                href="https://www.laruence.com/tag/php-8" title="View all posts tagged PHP 8">PHP 8</a>
                            <a href="https://www.laruence.com/tag/php8" title="View all posts tagged PHP8">PHP8</a>

                            <a href="https://www.laruence.com/tag/match" title="View all posts tagged match">match</a>
                            <a href="https://www.laruence.com/tag/match-expression%ef%bc%8cswitch"
                                title="View all posts tagged match expression，switch">match expression，switch</a> <a
                                href="https://www.laruence.com/tag/php-8" title="View all posts tagged PHP 8">PHP 8</a>
                            <a href="https://www.laruence.com/tag/php8" title="View all posts tagged PHP8">PHP8</a>

                            <a href="https://www.laruence.com/tag/match" title="View all posts tagged match">match</a>
                            <a href="https://www.laruence.com/tag/match-expression%ef%bc%8cswitch"
                                title="View all posts tagged match expression，switch">match expression，switch</a> <a
                                href="https://www.laruence.com/tag/php-8" title="View all posts tagged PHP 8">PHP 8</a>
                            <a href="https://www.laruence.com/tag/php8" title="View all posts tagged PHP8">PHP8</a>

                            <a href="https://www.laruence.com/tag/match" title="View all posts tagged match">match</a>
                            <a href="https://www.laruence.com/tag/match-expression%ef%bc%8cswitch"
                                title="View all posts tagged match expression，switch">match expression，switch</a> <a
                                href="https://www.laruence.com/tag/php-8" title="View all posts tagged PHP 8">PHP 8</a>
                            <a href="https://www.laruence.com/tag/php8" title="View all posts tagged PHP8">PHP8</a>

                        </div>


                    </div>


                    <div class="center">
                        <h2>
                            <a href="neirong.html">图形推荐</a>
                        </h2>
                        <div class="post-content">

                            <div class="layui-row layui-col-space15 tupianlist">

                                <div class="layui-col-md3 layui-col-xs6">
                                    <a href="https://www.13yd.com/517228.html" class="icon">
                                        <img src="https://image.9game.cn/s/9game/g/2018/5/14/20293666.png">
                                    </a>
                                    <em>碰碰糖果2</em>
                                </div>
                            
                                <div class="layui-col-md3 layui-col-xs6">
                                    <a href="https://www.13yd.com/534621.html" class="icon">
                                        <img src="https://image.9game.cn/s/9game/g/2018/1/11/19147766.png">
                                    </a>
                                    <em>万圣节化妆舞会</em>
                                </div>
                            
                                <div class="layui-col-md3 layui-col-xs6">
                                    <a href="https://www.13yd.com/533846.html" class="icon">
                                        <img src="https://image.game.uc.cn/2014/7/25/9819805.gif">
                                    </a>
                                    <em>消灭星星2：粉碎糖果</em>
                                </div>
                            
                                <div class="layui-col-md3 layui-col-xs6">
                                    <a href="https://www.13yd.com/503113.html" class="icon">
                                        <img src="https://media.9game.cn/gamebase/2021/4/27/227003500.png">
                                    </a>
                                    <em>神庙逃亡2</em>
                                </div>
                                <div class="layui-col-md3 layui-col-xs6">
                                    <a href="https://www.13yd.com/517228.html" class="icon">
                                        <img src="https://image.9game.cn/s/9game/g/2018/5/14/20293666.png">
                                    </a>
                                    <em>碰碰糖果</em>
                                </div>
                            
                                <div class="layui-col-md3 layui-col-xs6">
                                    <a href="https://www.13yd.com/534621.html" class="icon">
                                        <img src="https://image.9game.cn/s/9game/g/2018/1/11/19147766.png">
                                    </a>
                                    <em>万圣节化妆舞会</em>
                                </div>
                            
                                <div class="layui-col-md3 layui-col-xs6">
                                    <a href="https://www.13yd.com/533846.html" class="icon">
                                        <img src="https://image.game.uc.cn/2014/7/25/9819805.gif">
                                    </a>
                                    <em>消灭星星2：粉碎糖果</em>
                                </div>
                            
                                <div class="layui-col-md3 layui-col-xs6">
                                    <a href="https://www.13yd.com/503113.html" class="icon">
                                        <img src="https://media.9game.cn/gamebase/2021/4/27/227003500.png">
                                    </a>
                                    <em>神庙逃亡2</em>
                                </div>
                                <div class="layui-col-md3 layui-col-xs6">
                                    <a href="https://www.13yd.com/517228.html" class="icon">
                                        <img src="https://image.9game.cn/s/9game/g/2018/5/14/20293666.png">
                                    </a>
                                    <em>碰碰糖果</em>
                                </div>
                            
                                <div class="layui-col-md3 layui-col-xs6">
                                    <a href="https://www.13yd.com/534621.html" class="icon">
                                        <img src="https://image.9game.cn/s/9game/g/2018/1/11/19147766.png">
                                    </a>
                                    <em>万圣节化妆舞会</em>
                                </div>
                            
                                <div class="layui-col-md3 layui-col-xs6">
                                    <a href="https://www.13yd.com/533846.html" class="icon">
                                        <img src="https://image.game.uc.cn/2014/7/25/9819805.gif">
                                    </a>
                                    <em>消灭星星2：粉碎糖果</em>
                                </div>
                            
                                <div class="layui-col-md3 layui-col-xs6">
                                    <a href="https://www.13yd.com/503113.html" class="icon">
                                        <img src="https://media.9game.cn/gamebase/2021/4/27/227003500.png">
                                    </a>
                                    <em>神庙逃亡2</em>
                                </div>
                        
                            </div>


                           
                            
                         
                        </div>
                       
                    </div>
                    

                </div>
                <div class="layui-col-md4 layui-col-xs12">
                    <div class="ycenter" id="zuozhede1">
                        <div class="layui-row layui-col-space20">
                            <div class="layui-col-4 layui-col-xs4">
                                <img src="https://www.laruence.com/images/logo.jpg" style="width:100%;">
                            </div>

                            <div class="layui-col-8 layui-col-xs8 zuojiesao">
                                Laruence
                                PHP开发组核心成员, Zend顾问, PHP7及PHP8 JIT核心作者. Yaf等开源项目作者.
                            </div>
                        </div>

                    </div>
                    <div class="ycenter">
                        <form role="search" method="get" class="search-form" action="https://www.laruence.com/">
                            <label class="screen-reader-text" for="search-field">Search</label>
                            <input id="search-field" type="search" class="search-field" value="" name="s"
                                title="Search for:" placeholder="Search for...">
                            <input type="submit" class="search-submit" value="Search">
                        </form>
                    </div>

                    <div class="ycenter">
                        <h3>开源项目</h3>
                        <ul>
                            <li><a href="http://pecl.php.net/package/yaf" target="_blank"
                                    rel="noopener noreferrer">Yaf</a>: &nbsp;PHP Framework in PHP extension &nbsp;PHP
                                Framework in PHP extension &nbsp;PHP Framework in PHP extension &nbsp;PHP Framework in
                                PHP extension &nbsp;PHP Framework in PHP extension</li>
                            <li><a href="http://pecl.php.net/package/yar" target="_blank"
                                    rel="noopener noreferrer">Yar</a>: &nbsp;Light, concurrent RPC framework</li>
                            <li><a href="http://pecl.php.net/yac" target="_blank" rel="noopener noreferrer">Yac</a>:
                                &nbsp;PHP Contents cache</li>
                            <li><a href="https://github.com/laruence/yaconf" target="_blank"
                                    rel="noopener noreferrer">Yaconf</a>: &nbsp;PHP Configurations Container</li>
                            <li><a href="http://pecl.php.net/package/taint" target="_blank"
                                    rel="noopener noreferrer">Taint</a>: &nbsp;XSS code sniffer</li>
                            <li><a href="http://pecl.php.net/package/lua" target="_blank"
                                    rel="noopener noreferrer">Lua</a>: &nbsp;Embedded lua interpreter</li>
                            <li><a href="http://pecl.php.net/package/msgpack" target="_blank"
                                    rel="noopener noreferrer">MsgPack</a>: &nbsp;MessagePack in PHP extension</li>
                            <li><a href="http://pecl.php.net/package/couchbase" target="_blank"
                                    rel="noopener noreferrer">Couchbase</a>: &nbsp;Libcouchbase wrapper</li>
                            <li>See also: &nbsp;<a href="http://github.com/laruence">laruence@github</a></li>
                        </ul>
                    </div>

                    <div class="ycenter">
                        <h3>个人公众号</h3>
                        <div>
                            <img width="258" height="258"
                                src="https://www.laruence.com/medias/2020/03/qrcode_for_gh_2be27e841b9d_258.jpg">
                        </div>

                    </div>
                    <div class="ycenter">
                        <h3>分类</h3>
                        <div>
                            <select name="cat" id="cat" class="postform">
                                <option value="-1">Select Category</option>
                                <option class="level-0" value="2">GNU C/C++&nbsp;&nbsp;(11)</option>
                                <option class="level-0" value="3">Js/CSS&nbsp;&nbsp;(24)</option>
                                <option class="level-0" value="4">Linux/Unix&nbsp;&nbsp;(15)</option>
                                <option class="level-0" value="5">MySQL/PostgreSQL&nbsp;&nbsp;(7)</option>
                                <option class="level-0" value="6">PHP Extension&nbsp;&nbsp;(19)</option>
                                <option class="level-0" value="7">PHP7&nbsp;&nbsp;(9)</option>
                                <option class="level-0" value="733">PHP8&nbsp;&nbsp;(5)</option>
                                <option class="level-0" value="8">PHP应用&nbsp;&nbsp;(187)</option>
                                <option class="level-0" value="9">PHP源码分析&nbsp;&nbsp;(86)</option>
                                <option class="level-0" value="10">转载&nbsp;&nbsp;(34)</option>
                                <option class="level-0" value="11">随笔&nbsp;&nbsp;(109)</option>
                            </select>
                        </div>

                    </div>



                    <div class="ycenter">
                        <h3>标签</h3>
                        <div class="tagcloud"><a href="https://www.laruence.com/tag/apache"
                                class="tag-cloud-link tag-link-58 tag-link-position-1"
                                style="font-size: 11.083333333333pt;" aria-label="Apache (6 items)">Apache</a>
                            <a href="https://www.laruence.com/tag/apc"
                                class="tag-cloud-link tag-link-60 tag-link-position-2"
                                style="font-size: 11.083333333333pt;" aria-label="apc (6 items)">apc</a>
                            <a href="https://www.laruence.com/tag/bug"
                                class="tag-cloud-link tag-link-76 tag-link-position-3" style="font-size: 10.5pt;"
                                aria-label="bug (5 items)">bug</a>
                            <a href="https://www.laruence.com/tag/c"
                                class="tag-cloud-link tag-link-80 tag-link-position-4" style="font-size: 9pt;"
                                aria-label="C++ (3 items)">C++</a>
                            <a href="https://www.laruence.com/tag/core"
                                class="tag-cloud-link tag-link-104 tag-link-position-5"
                                style="font-size: 11.083333333333pt;" aria-label="core (6 items)">core</a>
                            <a href="https://www.laruence.com/tag/curl"
                                class="tag-cloud-link tag-link-110 tag-link-position-6" style="font-size: 9pt;"
                                aria-label="curl (3 items)">curl</a>
                            <a href="https://www.laruence.com/tag/extension"
                                class="tag-cloud-link tag-link-138 tag-link-position-7" style="font-size: 10.5pt;"
                                aria-label="Extension (5 items)">Extension</a>
                            <a href="https://www.laruence.com/tag/ie"
                                class="tag-cloud-link tag-link-198 tag-link-position-8" style="font-size: 9pt;"
                                aria-label="IE (3 items)">IE</a>
                            <a href="https://www.laruence.com/tag/javascript"
                                class="tag-cloud-link tag-link-220 tag-link-position-9"
                                style="font-size: 13.833333333333pt;" aria-label="javascript (14 items)">javascript</a>
                            <a href="https://www.laruence.com/tag/js"
                                class="tag-cloud-link tag-link-225 tag-link-position-10" style="font-size: 9pt;"
                                aria-label="js (3 items)">js</a>
                            <a href="https://www.laruence.com/tag/json"
                                class="tag-cloud-link tag-link-228 tag-link-position-11" style="font-size: 9pt;"
                                aria-label="json (3 items)">json</a>
                            <a href="https://www.laruence.com/tag/mysql"
                                class="tag-cloud-link tag-link-270 tag-link-position-12"
                                style="font-size: 9.8333333333333pt;" aria-label="mysql (4 items)">mysql</a>
                            <a href="https://www.laruence.com/tag/nginx"
                                class="tag-cloud-link tag-link-281 tag-link-position-13"
                                style="font-size: 9.8333333333333pt;" aria-label="nginx (4 items)">nginx</a>
                            <a href="https://www.laruence.com/tag/opcache"
                                class="tag-cloud-link tag-link-286 tag-link-position-14"
                                style="font-size: 9.8333333333333pt;" aria-label="opcache (4 items)">opcache</a>
                            <a href="https://www.laruence.com/tag/performance"
                                class="tag-cloud-link tag-link-300 tag-link-position-15" style="font-size: 10.5pt;"
                                aria-label="Performance (5 items)">Performance</a>
                            <a href="https://www.laruence.com/tag/php"
                                class="tag-cloud-link tag-link-305 tag-link-position-16" style="font-size: 22pt;"
                                aria-label="PHP (143 items)">PHP</a>
                            <a href="https://www.laruence.com/tag/php5-4"
                                class="tag-cloud-link tag-link-326 tag-link-position-17"
                                style="font-size: 9.8333333333333pt;" aria-label="PHP5.4 (4 items)">PHP5.4</a>
                            <a href="https://www.laruence.com/tag/php5-4%e6%96%b0%e7%89%b9%e6%80%a7"
                                class="tag-cloud-link tag-link-327 tag-link-position-18" style="font-size: 13.25pt;"
                                aria-label="PHP5.4新特性 (12 items)">PHP5.4新特性</a>
                            <a href="https://www.laruence.com/tag/php7"
                                class="tag-cloud-link tag-link-328 tag-link-position-19" style="font-size: 13pt;"
                                aria-label="PHP7 (11 items)">PHP7</a>
                            <a href="https://www.laruence.com/tag/php8"
                                class="tag-cloud-link tag-link-330 tag-link-position-20" style="font-size: 10.5pt;"
                                aria-label="PHP8 (5 items)">PHP8</a>
                            <a href="https://www.laruence.com/tag/php-8"
                                class="tag-cloud-link tag-link-737 tag-link-position-21" style="font-size: 9pt;"
                                aria-label="PHP 8 (3 items)">PHP 8</a>
                            <a href="https://www.laruence.com/tag/php-extension"
                                class="tag-cloud-link tag-link-311 tag-link-position-22"
                                style="font-size: 11.083333333333pt;" aria-label="PHP extension (6 items)">PHP
                                extension</a>
                            <a href="https://www.laruence.com/tag/php%e5%8e%9f%e7%90%86"
                                class="tag-cloud-link tag-link-335 tag-link-position-23"
                                style="font-size: 9.8333333333333pt;" aria-label="php原理 (4 items)">php原理</a>
                            <a href="https://www.laruence.com/tag/php%e5%ba%94%e7%94%a8"
                                class="tag-cloud-link tag-link-342 tag-link-position-24" style="font-size: 9pt;"
                                aria-label="PHP应用 (3 items)">PHP应用</a>
                            <a href="https://www.laruence.com/tag/php%e6%89%a9%e5%b1%95"
                                class="tag-cloud-link tag-link-344 tag-link-position-25" style="font-size: 9pt;"
                                aria-label="PHP扩展 (3 items)">PHP扩展</a>
                            <a href="https://www.laruence.com/tag/php%e6%ba%90%e7%a0%81"
                                class="tag-cloud-link tag-link-349 tag-link-position-26"
                                style="font-size: 9.8333333333333pt;" aria-label="php源码 (4 items)">php源码</a>
                            <a href="https://www.laruence.com/tag/php%e6%ba%90%e7%a0%81%e5%88%86%e6%9e%90"
                                class="tag-cloud-link tag-link-350 tag-link-position-27"
                                style="font-size: 12.333333333333pt;" aria-label="php源码分析 (9 items)">php源码分析</a>
                            <a href="https://www.laruence.com/tag/sapi"
                                class="tag-cloud-link tag-link-394 tag-link-position-28"
                                style="font-size: 9.8333333333333pt;" aria-label="SAPI (4 items)">SAPI</a>
                            <a href="https://www.laruence.com/tag/session"
                                class="tag-cloud-link tag-link-402 tag-link-position-29" style="font-size: 10.5pt;"
                                aria-label="session (5 items)">session</a>
                            <a href="https://www.laruence.com/tag/valgrind"
                                class="tag-cloud-link tag-link-458 tag-link-position-30" style="font-size: 9pt;"
                                aria-label="valgrind (3 items)">valgrind</a>
                            <a href="https://www.laruence.com/tag/vim"
                                class="tag-cloud-link tag-link-463 tag-link-position-31" style="font-size: 9pt;"
                                aria-label="vim (3 items)">vim</a>
                            <a href="https://www.laruence.com/tag/yac"
                                class="tag-cloud-link tag-link-476 tag-link-position-32"
                                style="font-size: 9.8333333333333pt;" aria-label="yac (4 items)">yac</a>
                            <a href="https://www.laruence.com/tag/yaf"
                                class="tag-cloud-link tag-link-478 tag-link-position-33" style="font-size: 14.5pt;"
                                aria-label="Yaf (17 items)">Yaf</a>
                            <a href="https://www.laruence.com/tag/yaf_loader"
                                class="tag-cloud-link tag-link-683 tag-link-position-34"
                                style="font-size: 9.8333333333333pt;" aria-label="Yaf_Loader (4 items)">Yaf_Loader</a>
                            <a href="https://www.laruence.com/tag/yar"
                                class="tag-cloud-link tag-link-482 tag-link-position-35" style="font-size: 10.5pt;"
                                aria-label="Yar (5 items)">Yar</a>
                            <a href="https://www.laruence.com/tag/zval"
                                class="tag-cloud-link tag-link-503 tag-link-position-36" style="font-size: 9pt;"
                                aria-label="zval (3 items)">zval</a>
                            <a href="https://www.laruence.com/tag/%e4%bc%98%e5%8c%96"
                                class="tag-cloud-link tag-link-516 tag-link-position-37" style="font-size: 8pt;"
                                aria-label="优化 (2 items)">优化</a>
                            <a href="https://www.laruence.com/tag/%e4%bd%8e%e6%a6%82%e7%8e%87core"
                                class="tag-cloud-link tag-link-518 tag-link-position-38" style="font-size: 8pt;"
                                aria-label="低概率core (2 items)">低概率core</a>
                            <a href="https://www.laruence.com/tag/%e5%86%85%e6%a0%b8"
                                class="tag-cloud-link tag-link-525 tag-link-position-39" style="font-size: 9pt;"
                                aria-label="内核 (3 items)">内核</a>
                            <a href="https://www.laruence.com/tag/%e5%8e%9f%e7%90%86"
                                class="tag-cloud-link tag-link-535 tag-link-position-40"
                                style="font-size: 9.8333333333333pt;" aria-label="原理 (4 items)">原理</a>
                            <a href="https://www.laruence.com/tag/%e5%bc%80%e5%8f%91php%e6%89%a9%e5%b1%95"
                                class="tag-cloud-link tag-link-561 tag-link-position-41" style="font-size: 9pt;"
                                aria-label="开发php扩展 (3 items)">开发php扩展</a>
                            <a href="https://www.laruence.com/tag/%e6%80%a7%e8%83%bd"
                                class="tag-cloud-link tag-link-572 tag-link-position-42" style="font-size: 11.5pt;"
                                aria-label="性能 (7 items)">性能</a>
                            <a href="https://www.laruence.com/tag/%e6%80%a7%e8%83%bd%e4%bc%98%e5%8c%96"
                                class="tag-cloud-link tag-link-573 tag-link-position-43" style="font-size: 9pt;"
                                aria-label="性能优化 (3 items)">性能优化</a>
                            <a href="https://www.laruence.com/tag/%e6%89%a9%e5%b1%95%e5%bc%80%e5%8f%91"
                                class="tag-cloud-link tag-link-578 tag-link-position-44"
                                style="font-size: 11.083333333333pt;" aria-label="扩展开发 (6 items)">扩展开发</a>
                            <a href="https://www.laruence.com/tag/%e6%ad%a3%e5%88%99"
                                class="tag-cloud-link tag-link-595 tag-link-position-45" style="font-size: 9pt;"
                                aria-label="正则 (3 items)">正则</a></div>
                    </div>

                </div>

            </div>

        </div>
    </div>
    <div class="footer">
        <div class="layui-container">
            © <a href="https://www.laruence.com" title="Home">风雪之隅</a>/ <a href="http://www.php.net"
                target="_blank"><img src="https://www.laruence.com/images/php_logo.png"></a>/ <a
                href="https://www.laruence.com/licence" title="licence" rel="licence copyright">博客声明</a>/ <a
                href="http://www.miibeian.gov.cn" target="_blank">京ICP备15032766号</a>/ Theme By <a
                href="https://www.competethemes.com/period/" title="Period">Compete Themes</a>
        </div>

    </div>

</body>

</html>
<script src="./Tpl/jquery.js"></script>
<script src="./Tpl/layui/layui.js"></script>

<script>
function Slideshow(NODE) {
    var tupiandiyi = $(NODE + ' img:first');
    if(tupiandiyi.length < 1){
        return ;
    }
    var img = new Image();
    img.src = tupiandiyi.attr("src");
    img.onload = function () {
        var widht = $(NODE).width();
        var bili = widht / this.width;
        var height = this.height * bili;
        var carousel = layui.carousel.render({
            elem: NODE,
            width: '100%',
            height: height + 'px',
            arrow: window.screen.width > 750 ? 'always' : 'none',
            indicator: window.screen.width > 750 ? "inside" : "none",
            trigger: "mouseover",
            interval: 5500,
            autoplay: true
        });
        carousel.QTU =true;
        carousel.DATA ={status: 1,data:[],start:0};
        carousel.Node = NODE + ' img';
        carousel.startX = 0;
        carousel.startY = 0;
        carousel.moveEndX = 0;
        carousel.moveEndY = 0;
        $(carousel.Node).each(function(index,tttt){
            carousel.DATA.data.push({alt:$(tttt).attr("alt"), pid: 109+index, src: $(tttt).attr("src"), thumb: ""});
        });
        $(carousel.Node).on("touchstart", function (e) {
            if (e.cancelable) {
                if (!e.defaultPrevented) {
                    e.preventDefault()
                }
            }
            carousel.startX = e.originalEvent.changedTouches[0].pageX;
            carousel.startY = e.originalEvent.changedTouches[0].pageY
        });
        $(carousel.Node).on("touchend", function (e) {
            if (e.cancelable) {
                if (!e.defaultPrevented) {
                    e.preventDefault()
                }
            }
            carousel.moveEndX = e.originalEvent.changedTouches[0].pageX;
            carousel.moveEndY = e.originalEvent.changedTouches[0].pageY;
            var X = carousel.moveEndX - carousel.startX;
            var Y = carousel.moveEndY - carousel.startY;
            if(X == 0 && Y == 0){
                if(carousel.QTU){
                    var gg = $(this).attr("src");
                    for(var xx in carousel.DATA.data){
                        var dd = carousel.DATA.data[xx];
                        if(dd.src == gg){
                            carousel.DATA.start = xx;
                        }
                    }

                    layer.photos({
                        photos: carousel.DATA 
                        
                    });

                }else{
                    var href = $(this).attr("href");
                    if (typeof (href) != "undefined") {
                        window.location.href = href
                    }
                }
                
            }   
            if (X > 5) {
                carousel.slide("sub")
            } else {
                if (X < -5) {
                    carousel.slide()
                }
            }
            if (Y > 50) {
                $("html,body").animate({
                    scrollTop: document.body.scrollTop -= 158
                }, Y * 1)
            } else {
                if (Y < -50) {
                    $("html,body").animate({
                        scrollTop: document.body.scrollTop += 158
                    }, -Y * 1)
                }
            }
        });
    }
}
var height = 0;

$(function () {
    var width = $("body").width();
    if (width <= 768) {
        if ($("#zuozhede1").length > 0) {
            var html = $("#zuozhede1").html();
            $("#zuozhede1").remove();
            $("#zuozhede").html('<div class="ycenter">' + html + '</div>');

        }
    }
    Slideshow('#test1');

    layui.rate.render({
        elem: '.layui-rate-node'
        ,readonly: true
        ,value: 2.5 
        ,half: true 
      
    });

    $(".postform").change(function (vv) {
        window.location.href = $(this).val();

    });
    $(".gengduocd").click(function () {
        if ($(".header ul").hasClass("layui-hide-xs")) {
            $(".header ul").removeClass("layui-hide-xs");
            if (height > 0) {
                $(".header ul").animate({
                    "max-height": height
                }, 300);
            } else {
                height = $(".header ul").height();
                $(".header ul").css({
                    "max-height": height
                });
            }

        } else {


            $(".header ul").animate({
                "max-height": '0px'
            }, 300, function () {

                $(".header ul").addClass("layui-hide-xs");
            });
        }

    });
});
</script>